Ext.onReady(function(){
// 开启快速提示功能
Ext.QuickTips.init();
Ext.form.Field.prototype.msgTarget ="qtip";

//表单开始
var loginFrom = new Ext.FormPanel({
    width:200,
 autoHeight: true,
 waitMsgTarget: true, /**//* true的意思是说表单提交时的等待信息在这个表单之内显示，而不是弹出框 */
 frame:true,
 border:false,
 labelWidth : 50,
 labelAlign : "right",
 labelPad : 0,// 标签与字段录入框之间的空白
 bodyStyle:"padding:5px 5px 5px,2px",
 layout :"form",
 defaults: {width: 150},
    defaultType: 'textfield',
 items:[
  {
   fieldLabel :"用户名",
   cls :"user",
   name :"username",
   style:"font-size: 15px",
   allowBlank : false,
   anchor:"95%"
  },
  {
   fieldLabel :"密&nbsp;&nbsp;&nbsp;码",
   inputType:"password",
   cls : "key",
   name :"password",
   style:"font-size: 15px",
   allowBlank : false ,
   anchor:"95%"
  },
  {
   fieldLabel :"验证码",
   name: 'validateCode',
      style:"font-size: 15px",
      maxLength: 4,
      width: 80,
      allowBlank:false 
  }
 ],
 buttons:[
  {
   text:"登录",
   type: 'submit',
   handler:function(){
    checkLogin();
   }
  },
  {
   text:"重置",
   handler:function(){
    loginFrom.form.reset();
   }
  }
 ],
 //键盘事件开始
 keys:[
     {
     key: [10,13],
     fn:checkLogin
  }  
 ]
 //键盘事件结束
});
//表单结束


function checkLogin()
{
    if(loginFrom.form.isValid())
    {
         loginFrom.form.doAction('submit',{
            url:'CheckLogin.aspx',//文件路径
   waitMsg:'正在验证用户...', /**//* 表示提交过程中间的等待信息。 */
            method:'post',//提交方法post或get
            params:'',
            success:function(form,action){
                if (action.result.msg=='ok') {
                        //document.location='index.html';
                     Ext.Msg.alert('提示窗口','提交已成功！');
                } else {
                     Ext.Msg.alert('登陆错误',action.result.msg);
                     loginFrom.form.reset();
                }
            },
            failure:function(){
                   Ext.Msg.alert('错误','服务器端出现错误请稍后再试！');
            }
          });
    }
}

CreateWin("loginWin","loginWin1",300,180,"管理员登录",true,true,false,false,loginFrom);

var bd = Ext.getDom('validateCode');     
var bd2 = Ext.get(bd.parentNode);    
bd2.createChild(
 [
  {tag:'span',html:''},
  {tag: 'img',id:'ImgVerifyCode', src: 'GetImageCode.aspx',align:'absbottom'},
  {tag:'span',html:'   <a href=# onclick=GetImgCode()>刷新</a>'}
 ]
);
});

function GetImgCode()
         {
              var randomnum = Math.random();
              var getimagecode = document.getElementById("ImgVerifyCode");
              getimagecode.src = "GetImageCode.aspx?"+randomnum;
         }